package com.ylc.project.service.impl.inner;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ylc.project.common.ErrorCode;
import com.ylc.project.exception.BusinessException;
import com.ylc.project.mapper.UserMapper;
import com.ylc.ylcapicommon.model.entity.User;
import com.ylc.ylcapicommon.service.InnerUserService;
import org.apache.commons.lang3.StringUtils;
import org.apache.dubbo.config.annotation.DubboService;
import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;

import javax.annotation.Resource;
import java.awt.geom.QuadCurve2D;

/**
 * @Author: ylc
 * @Description:权限验证，根据Ak查看数据库中是否有该用户存在
 */
@DubboService
public class InnerUserServiceImpl implements InnerUserService {
    @Resource
    private UserMapper userMapper;
    @Override
    public User getInvokeUser(String accessKey) {
        if(StringUtils.isAnyBlank(accessKey)){
            throw new BusinessException(ErrorCode.PARAMS_ERROR);
        }
        QueryWrapper<User> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("accessKey",accessKey);
        return userMapper.selectOne(queryWrapper);

    }
}
